package controller;

import lombok.Data;
import utils.BaseAction;

import java.io.IOException;
import java.io.PrintWriter;

@Data
public class UserAction extends BaseAction {
    private String username;
    private String password;

    public String checkLogin(){
        if ("admin".equals(username)&&"admin".equals(password)||"scott".equals(username)&&"tiger".equals(password)){
            getMapSession().put("username",username);
            return SUCCESS;
        }else {
            getRequest().setAttribute("msg","账号或者密码错误!请重新<a href='login.jsp'>登陆</a>");
            return "error";
        }
    }

    public String addUser() throws IOException {
        PrintWriter out=getResponse().getWriter();
        out.print("正在添加用户");
        return SUCCESS;
    }
}
